<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/sysoutUtil/inc.jsp" %>
    <title>企业列表</title>
</head>
<body>
<table class="table" id="AuthRepInfo-table" border="1"></table>
<script>
    $.ajax({
        url:'http://localhost:8071/AuthRepInfo/SelectAuthRepInfo',
        type:'get',
        dataType:'json',
        success:function(data){
            var str = "";
            var examStatus = 2;
            var  examStatus2=3;
            var str ='<tr>\n' +
                '<td>归属地</td>\n' +
                '<td>姓名</td>\n' +
                '<td>证件号码</td>\n' +
                '<td>认证状态</td>\n' +
                '<td>填写人身份</td>\n' +
                '<td>操作</td>\n' +
                '</td>\n' +
                '</tr>'
            for ( var i = 0; i < data.length; i++) {
                var examStatus3="";
                var examStatus1 = data[i].examStatus;
                if(examStatus1==1){
                    examStatus3="请求认证"
                }else{
                    examStatus3="认证失败"
                }
                var agentYn2="";
                var agentYn =  data[i].agentYn;
                if(agentYn==1){
                    agentYn2="代理人";
                }else{
                    agentYn2="普通人";
                }
                str +=
                    '<tr>\n' +
                    '<td>'+data[i].legPlaceInfo+'</td>\n' +
                    '<td>'+data[i].legName+'</td>\n' +
                    '<td>'+data[i].legIdcardNumber+'</td>\n' +
                    '<td>'+examStatus3+'</td>\n' +
                    '<td>'+agentYn2+'</td>\n' +
                    "<td><input type='button'value='认证通过'onclick='updateYes("+data[i].legId+","+examStatus+","+data[i].userId+")'><input type='button'value='认证驳回'onclick='updateNo("+data[i].legId+","+examStatus2+","+data[i].userId+")'> </td>\n"+
                    '</td>\n'+
                    '</tr>'
            }
            $("#AuthRepInfo-table").html(str)

        }
    })

    function updateYes(legId,examStatus,userid){
        alert(legId+"---"+examStatus+"-----"+userid)
        $.ajax({
            url:'http://localhost:8071/AuthRepInfo/UpdateAuthRepInfo',
            data:{
                "legId":legId,
                "examStatus":examStatus,
                "userid":userid
            },
            type:'put',
            dataType:'json',
            success:function(data){
                if(data==1){
                    alert("成功")
                }else{
                    alert("失败")
                }

            }
        })
    }
    //认证驳回
    function updateNo(legId,examStatus2,userid){
        alert(legId+"---"+examStatus2+"-----"+userid)
        $.ajax({
            url:'http://localhost:8071/AuthRepInfo/UpdateAuthRepInfo',
            data:{
                "legId":legId,
                "examStatus":examStatus2,
                "userid":userid
            },
            type:'put',
            dataType:'json',
            success:function(data){
                if(data==1){
                    alert("成功")
                }else{
                    alert("失败")
                }

            }
        })
    }
</script>

</body>
</html>
